import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterapp/chapter/seven/features_7_3_provider.dart';
import 'package:flutterapp/chapter/seven/features_7_4_color.dart';
import 'package:flutterapp/chapter/seven/features_7_4_theme.dart';
import 'package:flutterapp/chapter/seven/features_7_5_future_builder.dart';
import 'package:flutterapp/chapter/seven/features_7_5_stream_builder.dart';
import 'package:flutterapp/utils/navigator_utils.dart';

import 'features_7_1_will_pop_scope.dart';
import 'features_7_2_inherited_widget.dart';
import 'features_7_6_dialog.dart';

/// @date 2020/07/24  15:00
/// @author 程志强
/// @des

class SevenMain extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("功能型Widget"),
      ),
      body: Container(
        margin: EdgeInsets.only(left: 20.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: _list(context),
        ),
      ),
    );
  }

  List<Widget> _list(BuildContext context) => [
        RaisedButton(
            child: Text("导航返回拦截:WillPopScope"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, FeaturesWillPopScope())),
        RaisedButton(
            child: Text("数据共享:InheritedWidget"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, FeaturesInheritedWidget())),
        RaisedButton(
            child: Text("跨组件状态共享:Provider"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, ProviderWidget())),
        RaisedButton(
            child: Text("颜色"),
            onPressed: () => NavigatorUtil.goPageByPush(context, ColorRoute())),
        RaisedButton(
            child: Text("主题"),
            onPressed: () => NavigatorUtil.goPageByPush(context, ThemeRoute())),
        RaisedButton(
            child: Text("异步UI更新：FutureBuilder"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, FutureBuilderRoute())),
        RaisedButton(
            child: Text("异步UI更新：StreamBuilder"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, StreamBuilderRoute())),
        RaisedButton(
            child: Text("对话框详解"),
            onPressed: () =>
                NavigatorUtil.goPageByPush(context, DialogRoute1())),
      ];
}
